<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>内容页</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.4/jquery.js"></script>
</head>
<body>
    <div id="content">
        <div class="box"></div>
    </div>
    <script>
        //进入内容页将文章内容显示出来
        $(function(){
            let aid = getLoctionParams('aid');
            console.log('AID::',aid);
            $.ajax({
                url:'https://cache.iminutes.cn/api/soft/details.html',
                type:"GET",
                data:{
                    laysize:aid
                },
                dataType:'json',
                success:(res)=>{
                    console.log(res);
                    //
                    let {data:article} = res;
                    console.log(article);
                    //字符串模板
                    let oBox = `
                    <div class="box">
                        <p>${article.title}-${article.click_num}</p>

                        <p>${article.content}</p>
                    </div>
                    `;
                    document.querySelector('#content').innerHTML=oBox;
                }
            });
        });

        //接收参数cid的值
        //根据cid的值去查询对应的内容....

        /**
         * @param 地址的某个参数
         */
        function getLoctionParams(param){
            let href = window.location.search;//?aid=1&cid=2
            //截取?后面的内容
            href = href.substring(1);
            console.log(href);//aid=1&cid=2
            //按照&拆分
            let hrefArr = href.split("&");
            console.log(hrefArr);
            //循环
            for(let i=0;i<hrefArr.length;i++){
                let signal = hrefArr[i].split('=');
                if(param==signal[0]){
                    return signal[1];
                }
            }
            return false;
        }

        let cid = getLoctionParams('cid');
        let aid = getLoctionParams('aid');
        console.log(cid);
        console.log(aid);

        //通过aid的值将aid=?的内容拿出来，这时候就是ajax
        /**
         *  接口地址:https://cache.iminutes.cn/api/soft/detail.html
            请求参数:laysize
            请求方式:POST
         */






    </script>
</body>
</html>